package com.servlet.user;

import com.bean.Department;
import com.service.EmployeeService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;


@WebServlet("/user/getDeptServlet")
public class GetDeptServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        EmployeeService employeeService=new EmployeeService();
        ArrayList<Department> departments= new ArrayList<>();
        departments= (ArrayList<Department>) employeeService.getDept();
        req.setAttribute("depts",departments);
        req.getRequestDispatcher("usersearchdept.jsp").forward(req, resp);
    }
}
